<template>
	<view class="black">
		<!-- <image src="http://122.152.205.72:88/superhero/MARVEL/Venom/cover.png" mode="widthFix"></image> -->
		<image :src="cover" mode="widthFix" @longpress="operator"></image>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				cover:''
			}
		},
		methods: {
			operator(){
				//长按图片
				var me=this;
				uni.showActionSheet({
					itemList:["保存图片到本地"],
					success:function(res){
						// debugger
						if(res.tapIndex==0){
							// console.log("进入下载...")
							
							//加载loading
							uni.showLoading({
								title:"图片保存中..."
							})
							//下载文件
							uni.downloadFile({
								url:me.cover,
								success:function(result){
									var tempFilePath=result.tempFilePath
									console.log(tempFilePath);
									
									//保存到系统相册
									uni.saveImageToPhotosAlbum({
										filePath:tempFilePath,
										success:function(){
											 //显示消息提示框
											uni.showToast({
												title:"保存成功",
												duration:2000
											})
											
										},
										complete:function(){
											uni.hideLoading()
										},
										
									})
									console.log(111)
								}
							})
						}
					}
				})
			}
		},
		//通过params获取
		onLoad(params){
			// console.log(params);
			var cover=params.cover;
			this.cover=cover;
			// 通过api修改导航栏的属性  全部显示上面
			uni.setNavigationBarColor({
				frontColor:"#ffffff",
				backgroundColor:"#000000",
			})
		}
		
	}
</script>

<style>
.black{
	background-color: #000000;
	height: 100%;
	width: 100%;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	position: fixed;
}
</style>
